package com.xzr.kutumanager.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;

/**
 * @Author：徐志荣
 * @Date：2023/7/18 下午 4:43
 * <p>
 * 统一异常拦截处理类
 */

@RestControllerAdvice

public class MyExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public Object exceptionAdvice(Exception e) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("state", -1);
        result.put("msg", "程序出现异常" + e.getMessage());
        result.put("data", "");
        return result;
    }
}
